#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int mod = 998244353;
const int N = 5e5+10;
const int inv3 = (mod + 1) / 3;

int rev[N << 2],Wn[N << 2],rWn[N << 2],A[N << 2],B[N << 2],ans[N],len,n;
char s[N];

ll qp(ll x,int t) {ll res = 1;for(;t;t >>= 1,x = x * x % mod) if(t & 1) res = res * x % mod; return res;}

void init_Pre_NTT() {for(int h = 1;h < (N << 2);h <<= 1) Wn[h] = qp(3,(mod - 1) / h),rWn[h] = qp(inv3,(mod - 1) / h);}

void init_NTT(int l) {for(len = 1;len <= 2 * l;len <<= 1); for(int i = 1;i < len;i++) rev[i] = rev[i >> 1] >> 1 | (i & 1 ? len >> 1 : 0);}

int upd(int x){return x + (x >> 31 & mod);}

void NTT(int *f) {
	for(int i = 1;i < len;i++) if(i < rev[i]) swap(f[i],f[rev[i]]);
	for(int h = 2;h <= len;h <<= 1) {
		int wn = Wn[h];
		for(int i = 0;i < len;i += h) {
			int ww = 1;
			for(int j = i;j < i + h / 2;j++) {
				int u = f[j],v = (ll) f[j + h / 2] * ww % mod; ww = (ll) ww * wn % mod;
				f[j] = upd(u + v - mod),f[j + h / 2] = upd(u - v);
			}
		}
	}
}

void IDFT(int *f){
	for(int i = 1;i < len;i++) if(i < rev[i]) swap(f[i],f[rev[i]]);
	for(int h = 2;h <= len;h <<= 1) {
		int wn = Wn[h];
		for(int i = 0;i < len;i += h) {
			int ww = 1;
			for(int j = i;j < i + h / 2;j++) {
				int u = f[j],v = (ll) f[j + h / 2] * ww % mod; ww = (ll) ww * wn % mod;
				f[j] = upd(u + v - mod),f[j + h / 2] = upd(u - v);
			}
		}
	}
	reverse(f + 1,f + len); int invv = qp(len,mod - 2); for(int i = 0;i < len;i++) f[i] = (ll) f[i] * invv % mod;
}

void solve(){
	n = in; scanf("%s",s + 1); for(int i = 1;i <= n;i++) ans[i] = 0; init_NTT(n);
	for(int i = 1;i <= n;i++) A[i] = s[i] == 'V' , B[n - i + 1] = s[i] == 'K'; A[0] = 0; for(int i = n + 1;i < len;i++) A[i] = B[i] = 0;
	NTT(A); NTT(B); for(int i = 0;i < len;i++) A[i] = (ll) A[i] * B[i] % mod; IDFT(A);
	for(int i = 1;i <= n;i++) ans[i] += A[i + n + 1];
	for(int i = 1;i <= n;i++) A[i] = s[i] == 'K' , B[n - i + 1] = s[i] == 'V'; A[0] = 0; for(int i = n + 1;i < len;i++) A[i] = B[i] = 0;
	NTT(A); NTT(B); for(int i = 0;i < len;i++) A[i] = (ll) A[i] * B[i] % mod; IDFT(A);
	for(int i = 1;i <= n;i++) ans[i] += A[i + n + 1];
	vec tot;
	for(int i = 1;i <= n;i++) {
		if(ans[i]) continue;
		bool f = 0;
		for(int j = i + i;j <= n;j += i) f |= ans[j];
		if(!f) tot.pb(i);
	}
	printf("%u\n",tot.size());
	sort(tot.begin(),tot.end()); for(auto y : tot) printf("%d ",y); puts("");
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	init_Pre_NTT(); for(int t = in;t;t--) solve();
	return 0;
}
